<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>组件的data</title>
    <script src="./lib/vue-2.6.12.js"></script>
</head>

<body>
    <div id="app">
        <counter></counter>
        <hr>
        <counter></counter>
        <hr>
        <counter></counter>
        <hr>
    </div>

    <template id="tmpl">
        <div>
            <input type="button" value="+1" @click="add">
            <h3>{{count}}</h3>
        </div>
    </template>

    <script>
        let dataObj = { count: 0 };

        Vue.component('counter', {
            template: '#tmpl',
            data() {
                // return dataObj;
                return { count: 0 }
            },
            methods: {
                add() {
                    this.count++;
                }
            },
        });

        let vm = new Vue({
            el: '#app',
            data: {

            },
            methods: {

            }
        });

    </script>
</body>

</html>